import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CookingVO, CookingForm, CookingQuery } from '@/api/canteen/cooking/types';

/**
 * 查询烹饪管理列表
 * @param query
 * @returns {*}
 */

export const listCooking = (query?: CookingQuery): AxiosPromise<CookingVO[]> => {
  return request({
    url: '/canteen/cooking/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询烹饪管理详细
 * @param cookingId
 */
export const getCooking = (cookingId: string | number): AxiosPromise<CookingVO> => {
  return request({
    url: '/canteen/cooking/' + cookingId,
    method: 'get'
  });
};

/**
 * 新增烹饪管理
 * @param data
 */
export const addCooking = (data: CookingForm) => {
  return request({
    url: '/canteen/cooking',
    method: 'post',
    data: data
  });
};

/**
 * 修改烹饪管理
 * @param data
 */
export const updateCooking = (data: CookingForm) => {
  return request({
    url: '/canteen/cooking',
    method: 'put',
    data: data
  });
};

/**
 * 删除烹饪管理
 * @param cookingId
 */
export const delCooking = (cookingId: string | number | Array<string | number>) => {
  return request({
    url: '/canteen/cooking/' + cookingId,
    method: 'delete'
  });
};
